package com.csc.springcore.services;

import java.util.List;

import com.csc.springcore.dao.EmployeeDAO;
import com.csc.springcore.models.Employee;

/**
 * Handles all the business logic in the employee management application
 * @author leanhduy
 *
 */
public class EmployeeService {
	private EmployeeDAO employeeDAO;

	/**
	 * Set the employeeDAO object
	 * @param employeeDAO: The EmployeeDAO object
	 */
	public void setEmployeeDao(EmployeeDAO employeeDAO) {
		this.employeeDAO = employeeDAO;
	}

	/**
	 * Print all employees in the db
	 */
	public void printEmployeeList() {
		List<Employee> empList = employeeDAO.getEmployeeList();
		for (Employee e : empList) {
			System.out.println(e.toString());
		}
	}

	/**
	 * Find an employee in the database based on the given id
	 * @param id: Employee's Id
	 */
	public void findEmployeeById(int id) {
		Employee employee = employeeDAO.findEmployeeById(id);
		if (employee != null) {
			System.out.println("Found employee!");
			System.out.println(employee.toString());
		} else {
			System.out.println("Cannnot found employee!");
		}
	}

}
